<template>
  	<div id="selectAddress">
  		<header>
  			<i @click="goBack()"></i>
  			<div>选择收货地址</div>
  		</header>
  		<div class="box">
  			<label @change='selectAddress' class="address" v-for='(item,index) in list' :key='index'>
  				<p>收货人:<b>{{JSON.parse(item.content).name}}</b><i>{{JSON.parse(item.content).phone}}</i></p>
  				<div>收货地址:<i>{{JSON.parse(item.content).selectCity + JSON.parse(item.content).detailAddress}}</i></div>
  				<input type="radio" :value='item.content' v-model='address'>
  				<i></i>
  			</label>
  			<router-link :to="{name:'addAddress',query:{prevPath:'selectAddress'}}" class="addAddress">
  				<i>+</i>
  				<span>添加收货地址</span>
  			</router-link>
  		</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				list: [],
                userid: "",
				address: ''
			}
		},
		components: {

		},
		methods: {
			goBack() {
				this.$router.back();
			},
			selectAddress()	{
				console.log(this.address);
                localStorage.setItem("selectAddress", this.address);
                this.$router.back();
			},
            getAddress() {
                this.userid = localStorage.getItem("loginMobile");
                console.log(this.userid);
                this.$api.get(this.$api.baseURLSchool,"selectdata2/user_relative?user_id="+this.userid+"&type=address",{},r => {
                    console.log(r);
                    if(r.data.ret == 1) {
                        this.list = r.data.info;
                    }
                    
                },err => {
                    console.log(err);
                })
            },
		},
		created() {
            this.getAddress();

		},
		mounted() {

		}
	}
</script>
<style lang="scss">
</style>
